package cn.qiyu5522.tk_ems.config;


import com.github.xiaoymin.knife4j.spring.annotations.EnableKnife4j;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Import;
import springfox.bean.validators.configuration.BeanValidatorPluginsConfiguration;
import springfox.documentation.builders.ApiInfoBuilder;
import springfox.documentation.builders.PathSelectors;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.service.Contact;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2;

import static springfox.documentation.builders.RequestHandlerSelectors.basePackage;

/**
 * @BelongsProject: tk_ems
 * @BelongsPackage: com.example.tk_ems.config
 * @Author: TangQi
 * @CreateTime: 2023-01-03  10:19
 * @Description: TODO
 * @Version: 1.0
 */
@Configuration
@EnableSwagger2
@EnableKnife4j
@Import(BeanValidatorPluginsConfiguration.class)
public class Knife4jConfiguration  {

    @Bean
    public Docket adminApiConfig() {
        return new Docket(DocumentationType.SWAGGER_2)
                .apiInfo(adminApiInfo())
                .groupName("adminAPI")
                .select()
                .apis(basePackage("cn.qiyu5522.tk_ems.controller.admin"))
                .paths(PathSelectors.any())
                .build();

    }
    private springfox.documentation.service.ApiInfo adminApiInfo() {
        return new ApiInfoBuilder()
                .title("就业信息后台管理系统 API 文档")
                .description("本文档描述了就业信息后台管理系统的各个模块的接口调用方法")
                .version("1.6")
                .contact(new Contact("Tonkey", "http://www.qiyu5522.cn", "1480056419@qq.com"))
                .build();
    }


    @Bean
    public Docket webApiConfig() {
        /*
         * documentationType 文档类型
         * */
        return new Docket(DocumentationType.SWAGGER_2)
                .groupName("webApi")
                .apiInfo(webApiInfo())
                .select()
                .apis(basePackage("cn.qiyu5522.tk_ems.controller.api"))
                .paths(PathSelectors.any())
                .build();
    }

    private ApiInfo webApiInfo() {
        return new ApiInfoBuilder()
                .title("就业网站 API 文档")
                .description("本文档描述了就业网站的各个模块的接口调用方法")
                .version("1.6")
                .contact(new Contact("Tonkey", "http://www.qiyu5522.cn", "1480056419@qq.com"))
                .build();
    }
}
